from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import os
from math import sqrt

def scanAllImages(folderPath):
    extensions = ['.%s' % fmt.data().decode("ascii").lower() for fmt in QImageReader.supportedImageFormats()]
    images = []

    for root, dirs, files in os.walk(folderPath):
        for file in files:
            if file.lower().endswith(tuple(extensions)):
                relativePath = os.path.join(root, file)
                path = os.path.abspath(relativePath)
                images.append(path)
    images.sort(key=lambda x: x.lower())
    return images

def distance(p):
    return sqrt(p.x() * p.x() + p.y() * p.y())